﻿IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[dsc_ViewCarteMuncaIstoric]'))
DROP VIEW [dbo].[dsc_ViewCarteMuncaIstoric]
GO


CREATE VIEW [dbo].[dsc_ViewCarteMuncaIstoric]
AS
SELECT     a.Marca, a.Nume_Pren, a.Cod_Unit, a.Luna, a.Anul, b.Cod_LocM, dbo.pFunctii.Den_Func, dbo.pPerson.DataUnit, dbo.pPerson.DataPrAnga,dbo.pFunctii.Cod_Func
FROM         dbo.pPersSal AS a INNER JOIN
                      dbo.pLocMunca AS b ON a.Cod_Unit = b.Cod_Unit AND a.Cod_LocM = b.Cod_LocM INNER JOIN
                      dbo.pFunctii ON a.Cod_Unit = dbo.pFunctii.Cod_Unit AND a.Cod_Func = dbo.pFunctii.Cod_Func AND a.Luna = dbo.pFunctii.Luna AND 
                      a.Anul = dbo.pFunctii.Anul INNER JOIN
                      dbo.pPerson ON a.Cod_Unit = dbo.pPerson.Cod_unit AND a.Marca = dbo.pPerson.Marca

GO